package katas.recursion;

public class Recursion {

	/**
	 * Calculate factorial of n
	 */
	private int factorial(int n){
		if(n == 1)
			return 1;
		else
			return n * factorial(n-1) ;
	}
	
	/**
	 * Print number sequence from n to 0
	 */
	private void printSequence(int n){
		if(n == 0)
			System.out.print(n);
		else{
			System.out.print(n + " ");
			printSequence(n - 1);
		}
		
	}
	
	/**
	 * Print number sequence from 0 to n
	 */
	private void printSequenceReverse(int n){
		if(n == 0)
			System.out.print(0 + " ");
		else{
			printSequenceReverse(n - 1);
			System.out.print(n + " ");
		}
	}
	
	/**
	 * Reverse string
	 */
	private void reverseString(String s){
		if(s.length() == 1)
			System.out.print(s);
		else{
			reverseString(s.substring(1));
			System.out.print(s.charAt(0));
		}
	}
	
	/**
	 * Check for prime number
	 */
	private boolean checkPrime(int n){
		if(n > 1)
			return _checkPrime(n, 2);
		else
			return false;
	}
	
	private boolean _checkPrime(int n, int m){
		if(m == n)
			return true;
		else{
			if(n % m == 0)
				return false;
			else
				return _checkPrime(n, m+1);
		}
	}
	
	public static void main(String[] args) {
		Recursion r = new Recursion();
		
		//System.out.println(r.factorial(20));
		for (int i = 0; i < 72; i++) {
			if(r.checkPrime(i))
				System.out.print(i + " ");
		}
		
	}
}
